package cn.com.cifi.mars.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.com.cifi.mars.common.exception.MsgException;
import cn.com.cifi.mars.constant.CodeEnum;
import cn.com.cifi.mars.entity.MdmGroupBld;
import cn.com.cifi.mars.mapper.mars.GroupBldMapper;
import cn.com.cifi.mars.service.GroupBldService;

/**
 * <p>
 * （主数据）组团楼栋关系表 服务实现类
 * </p>
 *
 * @author yyd
 * @since 2019-09-24
 */
@Service
public class GroupBldServiceImpl extends ServiceImpl<GroupBldMapper, MdmGroupBld> implements GroupBldService {

    @Autowired
    private GroupBldMapper groupBldMapper;

    //查询最新投资版组团业态关系
    @Override
    public List<MdmGroupBld> selectNewestByFid(String projectFid, String versionType, String versionCode, int isDel) {
        List<MdmGroupBld> groupBldList = groupBldMapper.selectNewestByFid(projectFid, versionType, versionCode, isDel);
        if(CollectionUtils.isEmpty(groupBldList)){
            throw new MsgException(CodeEnum.NON_GROUPBLD_AREAPART);
        }

        return groupBldList;
    }

    @Override
    public List<MdmGroupBld> selectVersionByStageAndCode(String projectFid, String versionStage, String versionCode, int isDel) {

        List<MdmGroupBld> groupBldList = groupBldMapper.selectAppointVersionByFid(projectFid, versionStage, versionCode, isDel);
        if(CollectionUtils.isEmpty(groupBldList)){
            throw new MsgException(CodeEnum.NON_GROUPBLD_AREAPART);
        }

        return groupBldList;
    }

	@Override
	public void inertBatch(List<MdmGroupBld> mdmGroupBldList) {
		 groupBldMapper.insertBatch(mdmGroupBldList);
	}
}
